Selected Row Handling

Handle Selected Record on a Button Click

Description
This customization shows how to add a custom button to a table panel and handle the processing for the selected rows in the table panel.
Variables
Table Control Class
Select a table control
Table Name
Select the database table.
First Field Value
Select the First field to concatenate
Second Field Value
Select the Second field to concatenate
Display Control
Select a control to display concatenated string
Button Control
Select the newly added button
Applies to
TableControl class
Code
 
''' 
''' Call custom application logic when a row is selected in a table control in your application. 
''' 
Public Overrides Sub ${Button Control}_Click(ByVal sender As Object, ByVal args As EventArgs)                
    
    Try
        
        ' Start Transaction  
        DbUtils.StartTransaction()
        
        ' Get selected record controls
        Dim selectedRecords As ${Table Name}TableControlRow() = Me.GetSelectedRecordControls()
        
        ' If there are selected Records then        
        If (selectedRecords.Length > 0) Then  
        
            ' Get record control and do your custom business processing here.        
            Dim rec As ${Table Name}TableControlRow
            For Each rec In selectedRecords

				' Get the database record and do your custom business processing here.
                 Dim myRec As ${Table Name}Record = rec.GetRecord
                
				' Concatenate two fields and display them in a control.
                 rec.${Display Control}.Text = myRec.${First Field Value}.ToString() + " " + myRec.${Second Field Value}.ToString()
                
              
            Next                     
            DbUtils.CommitTransaction()
            
        Else
			' Display message to prompt record selection.
			BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(Me, "Message", "Please select a record")
					 
        End If
		
    Catch ex As Exception
        DbUtils.RollBackTransaction()

        'Report the error message to the user
        BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(Me, "UNIQUE_SCRIPT", ex.Message)
    Finally
    
        ' End Transaction  
        DbUtils.EndTransaction()
    End Try
End Sub
     

Terms of Service Privacy Statement